Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: project structure #12

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open

Conversation

cmdoret
Copy link
Member

@cmdoret cmdoret commented Feb 20, 2025

Change summary

Project layout

General cleanup to match best practice recommendations on project structure:

Reusability

  • the path to the shapes file is now read from an env variable instead of hardcoded
  • a SHAPES_URL variable can be given to download the shapes on container startup
  • remove shapes file from the git repo. Instead, the entrypoint downloads it dynamically on server startup
  • add .example.env file for centralized overview of env variables
  • remove specific mentions of the imaging plaza ontology

Modularity

The REST API and web application have been separated more clearly. This provides a smaller image with potentially fewer vulnerabilities for headless use-cases.

Currently: api image: 160MB, webapp image: 531MB

  • webapp dependencies (streamlit) are now an optional dependency group in pyproject.toml
    • install only api pip install .
    • install api+webapp pip install '.[webapp]'
  • Dockerfile is now multi-stage, with a api stage followed by a webapp stage.
    • This allows to build two separate images, one with only the rest api (image:version) and one with the api + webapp (<image>:<version>-webapp)

Development tools

Adds minimal tooling for development:

  • Optional dependency groups for development and testing
  • A makefile with standardized recipes for operations:
    • docker image management
    • project setup (install + dev dependencies)
    • code formatting

Usage

Just type make to see what operations are available with help messages. The rest should be straight forward.

Notes

  • The large diff in python files is due to running ruff format to ensure standardized formatting across source files.
  • This does not use a venv due to limitations imposed by the upstream alpine base image (from topbraid).
    • streamlit depends on pyarrow, which cannot be installed with pip on alpine, it needed to be installed at system level with apk, making it impossible (afaik) to use a venv separated from the system.

Questions

  • Do we really need the current tests? they directly test the shacl tool. I would suggest dropping them and testing it through the web server. (in a dedicated PR)

@cmdoret cmdoret self-assigned this Feb 20, 2025
@cmdoret cmdoret requested review from caviri and rmfranken February 21, 2025 18:59
@cmdoret cmdoret marked this pull request as ready for review February 21, 2025 18:59
@rmfranken
Copy link
Member

rmfranken commented Feb 22, 2025

😮 edit: praise: great work Cyril!

To address your question: I don't think the testing - especially in it's current form with imaging plaza specific failing shapes and inferencing. To test a SHACL api we should be able to use something more generic, but honestly - I'm not sure whether it's our responsibility to test the SHACL api using shapes. Then we are not testing the API, but the engine - which is not our concern. So I agree - let's drop these tests.

Also, I really appreciate the increased genericness and use of env variable to point to a shapes URL. Maybe we could even promote this API on the TopQuadrant repo to get further feedback + contributions from the community.

@cmdoret cmdoret linked an issue Feb 23, 2025 that may be closed by this pull request
@caviri
Copy link
Contributor

caviri commented Feb 24, 2025

Thank you a lot @cmdoret! This looks great. I'll add my review during this week.

@rmfranken could you try this component with Plaza in local?

Regarding tests, those are pretty old and originally used for testing the scripts more than the microservice. No problem on dropping those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make shacl-api agnostic
3 participants